package com.sntk.organauthomanager.infrastructure.db.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.Date;

/**
 * @ClassName: UserEntity
 * @author: wgchao
 * @createTime: 2020/7/21 8:36 AM
 * @Description: TODO
 */
@Table(name = "sys_organ_user_info", uniqueConstraints = @UniqueConstraint(columnNames = {"uname"}))
@org.hibernate.annotations.Table(appliesTo = "sys_organ_user_info", comment = "用户信息")
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    //账户名-唯一
    @Column(name = "uname", length = 20, columnDefinition="varchar(20) COMMENT '账户名'", nullable = false)
    private String uname;

    //机构编号
    @Column(name = "institution_number", length = 100, columnDefinition="varchar(100) COMMENT '所属机构编号'", nullable = false)
    private String institutionNumber;

    //认证密码(加密后)
    @Column(name = "password", length = 100, columnDefinition="varchar(100) COMMENT '账户密码'", nullable = false)
    private String password;

    //用户名称
    @Column(name = "user_name", length = 50, columnDefinition="varchar(50) COMMENT '用户名称'", nullable = false)
    private String userName;

    @Column(name = "his_user_code", length = 50, columnDefinition="varchar(20) COMMENT '用户对应his编号'")
    private String hisCode;

    @Column(name = "his_department_code", length = 50, columnDefinition="BIGINT COMMENT '用户默认his科室编码'")
    private Long hisDepartmentCode;

    //速记码
    @Column(name = "shorthand_code", length = 50, columnDefinition="varchar(50) COMMENT '速记码'", nullable = false)
    private String shorthandCode;

    //联系电话
    @Column(name = "contact_number", length = 20, columnDefinition="varchar(20) COMMENT '联系电话'")
    private String phoneNumber;

    //用户类型 管理员/普通用户
    @Column(name = "user_type", columnDefinition="integer COMMENT '用户类型 0:管理员 1：普通'")
    private Integer userType;

    //备注
    @Column(name = "remark", length = 200, columnDefinition="varchar(200) COMMENT '备注'")
    private String remark;

    @Column(name = "disabled", columnDefinition="bit(1) COMMENT '禁用标识'", nullable = false)
    private Boolean disabled;

    @Column(name = "del", nullable = false)
    private Boolean del;

    @Column(name = "create_time")
    private Date createTime;

    @Column(name = "creator", length = 50)
    private String creator;

    @Column(name = "last_update_time")
    private Date lastUpdateTime;

    @Column(name = "last_updator", length = 50)
    private String lastUpdator;

    //乐观锁 ObjectOptimisticLockingFailureException异常
    @Version
    private Long version;
}
